import { createRouter, createWebHistory, createWebHashHistory } from "vue-router";
import Layout from "@/layout/main.vue";
import { qiankunWindow } from "vite-plugin-qiankun/dist/helper";

const routes = [
  {
    path: "/",
    component: Layout,
    redirect: "/user",
    children: [
      {
        path: "user",
        name: "user",
        component: () => import("@/views/user/index.vue"),
      },
    ],
  },
];

const router = createRouter({
  routes,
  // 判断是否是qiankun环境
  history: createWebHistory(qiankunWindow.__POWERED_BY_QIANKUN__ ? "/one-son" : ""),
});

/**
 * 全局前置守卫
 */
router.beforeEach((to, from) => {});

export default router;
